package operation;

import book.Book;
import book.bookList;

import java.util.Scanner;

public class Borrowoperation implements Listoperation{
    @Override
    public void work(bookList booklist) {
        System.out.println("借阅图书...");
        System.out.println("请输入你要借阅的图书的名字:");
        Scanner sc=new Scanner(System.in);
        String name=sc.nextLine();
        for (int i = 0; i < booklist.getUsesize(); i++) {
            Book book=booklist.getBooks(i);
            if(book.isBorrowed()==true){
                System.out.println("该书已经被借出");
                return ;
            }
            if(book.getName().equals(name)){
                book.setBorrowed(true);
                System.out.println("借阅成功");
                return ;
            }
        }
        System.out.println("未找到你要借阅的书");
        return ;
    }
}
